using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MetroUI.Forms;

namespace QLKho.GUI
{
    public partial class frmDemo : Form
    {
        public frmDemo()
        {
            InitializeComponent();
        }
        public frmDemo(string TenChucNang)
        {
            InitializeComponent();
            fn_ChonGiaoDien(TenChucNang);
        }
        public frmDemo(Int32 MaMatHang, string TenMatHang, Int32 MaDonViLe)
        {
            InitializeComponent();
            uc_KhuyenMai ucKhuyenMai = new uc_KhuyenMai();
            ucKhuyenMai.Location = new Point(0, 0);
            ucKhuyenMai.Dock = DockStyle.Fill;
            ucKhuyenMai.ToKhuyenMai(MaMatHang, TenMatHang, MaDonViLe);
            ucKhuyenMai.Close = new uc_KhuyenMai.CloseForm(ReceiveEvent);
            this.Controls.Add(ucKhuyenMai);
        }
        private void fn_ChonGiaoDien(string sTenGiaoDien)
        {
            try
            {
                switch (sTenGiaoDien)
                {
                    case "HeThong":
                        uc_NguoiDung ucNguoiDung = new uc_NguoiDung();
                        ucNguoiDung.Location = new Point(0, 0);
                        ucNguoiDung.Dock = DockStyle.Fill;
                        ucNguoiDung.Close = new uc_NguoiDung.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucNguoiDung);
                        break;
                    case "DonVi":
                        uc_DonVi ucDonVi = new uc_DonVi();
                        ucDonVi.Location = new Point(0, 0);
                        ucDonVi.Dock = DockStyle.Fill;
                        ucDonVi.Close = new uc_DonVi.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucDonVi);
                        break;
                    case "KhuVuc":
                        uc_KhuVucKhachHang ucKhuVuc = new uc_KhuVucKhachHang();
                        ucKhuVuc.Location = new Point(0, 0);
                        ucKhuVuc.Dock = DockStyle.Fill;
                        ucKhuVuc.Close = new uc_KhuVucKhachHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucKhuVuc);
                        break;
                    case "Kho":
                        uc_Kho ucKho = new uc_Kho();
                        ucKho.Location = new Point(0, 0);
                        ucKho.Dock = DockStyle.Fill;
                        ucKho.Close = new uc_Kho.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucKho);
                        break;
                    case "LoaiMatHang":
                        uc_LoaiMatHang ucLoaiMatHang = new uc_LoaiMatHang();
                        ucLoaiMatHang.Location = new Point(0, 0);
                        ucLoaiMatHang.Dock = DockStyle.Fill;
                        ucLoaiMatHang.Close = new uc_LoaiMatHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucLoaiMatHang);
                        break;
                    case "LoaiKhachHang":
                        uc_LoaiKhachHang ucLoaiKhachHang = new uc_LoaiKhachHang();
                        ucLoaiKhachHang.Location = new Point(0, 0);
                        ucLoaiKhachHang.Dock = DockStyle.Fill;
                        ucLoaiKhachHang.Close = new uc_LoaiKhachHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucLoaiKhachHang);
                        break;
                    case "LoaiNhanVien":
                        uc_LoaiNhanVien ucLoaiNhanVien = new uc_LoaiNhanVien();
                        ucLoaiNhanVien.Location = new Point(0, 0);
                        ucLoaiNhanVien.Dock = DockStyle.Fill;
                        ucLoaiNhanVien.Close = new uc_LoaiNhanVien.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucLoaiNhanVien);
                        break;
                    case "NhomKhachHang":
                        uc_NhomKhachHang ucNhomKhachHang = new uc_NhomKhachHang();
                        ucNhomKhachHang.Location = new Point(0, 0);
                        ucNhomKhachHang.Dock = DockStyle.Fill;
                        ucNhomKhachHang.Close = new uc_NhomKhachHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucNhomKhachHang);
                        break;
                    case "NhaCungCap":
                        uc_NhaCungCap ucNhaCungCap = new uc_NhaCungCap();
                        ucNhaCungCap.Location = new Point(0, 0);
                        ucNhaCungCap.Dock = DockStyle.Fill;
                        ucNhaCungCap.Close = new uc_NhaCungCap.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucNhaCungCap);
                        break;
                    case "KhachHang":
                        uc_KhachHang ucKhachHang = new uc_KhachHang();
                        ucKhachHang.Location = new Point(0, 0);
                        ucKhachHang.Dock = DockStyle.Fill;
                        ucKhachHang.Close = new uc_KhachHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucKhachHang);
                        break;
                    case "NhapExcelKhachHang":
                        uc_NhapXuatExcelKhachHang ucExcelKhachHang = new uc_NhapXuatExcelKhachHang();
                        ucExcelKhachHang.Location = new Point(0, 0);
                        ucExcelKhachHang.Dock = DockStyle.Fill;

                        this.Controls.Add(ucExcelKhachHang);
                        break;
                    case "MatHang":
                        uc_MatHang ucMatHang = new uc_MatHang();
                        ucMatHang.Location = new Point(0, 0);
                        ucMatHang.Dock = DockStyle.Fill;
                        ucMatHang.Close = new uc_MatHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucMatHang);
                        break;
                    case "NhapExcelMatHang":
                        uc_NhapXuatExcelMatHang ucExcelMatHang = new uc_NhapXuatExcelMatHang();
                        ucExcelMatHang.Location = new Point(0, 0);
                        ucExcelMatHang.Dock = DockStyle.Fill;
                        ucExcelMatHang.Close = new uc_NhapXuatExcelMatHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucExcelMatHang);

                        break;
                    case "ChietKhauLoaiMatHang":
                        uc_ChietKhauLoaiMatHang ucChietKhauLoaiMatHang = new uc_ChietKhauLoaiMatHang();
                        ucChietKhauLoaiMatHang.Location = new Point(0, 0);
                        ucChietKhauLoaiMatHang.Dock = DockStyle.Fill;
                        ucChietKhauLoaiMatHang.Close = new uc_ChietKhauLoaiMatHang.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucChietKhauLoaiMatHang);
                        break;
                    //case "NhapKho":
                    //    uc_PhieuNhapKho ucPhieuNhap = new uc_PhieuNhapKho();
                    //    ucPhieuNhap.Location = new Point(0, 0);
                    //    ucPhieuNhap.Dock = DockStyle.Fill;
                    //    this.Controls.Add(ucPhieuNhap);
                    //    break;
                    case "NhapKhoChiTiet":
                        uc_PhieuNhapKhoChiTiet ucPhieuNhapCT = new uc_PhieuNhapKhoChiTiet();
                        ucPhieuNhapCT.Location = new Point(0, 0);
                        ucPhieuNhapCT.Dock = DockStyle.Fill;
                        this.Controls.Add(ucPhieuNhapCT);

                        break;
                    case "XuatKho":
                        frmLoaiXuatKho fLoaiXuatKho = new frmLoaiXuatKho();
                        DialogResult res = fLoaiXuatKho.ShowDialog();
                        if (res == DialogResult.OK)
                        {
                            uc_XuatKho ucXuatkho = new uc_XuatKho(frmLoaiXuatKho.ChucNang);
                            ucXuatkho.Location = new Point(0, 0);
                            ucXuatkho.Dock = DockStyle.Fill;
                            ucXuatkho.Close = new uc_XuatKho.CloseForm(ReceiveEvent);
                            this.Controls.Add(ucXuatkho);
                        }
                        else this.Close();
                        break;
                    case "XuatKhoChiTiet":
                        //uc_PhieuXuatKhoChiTiet ucPhieuXuatKhoChiTiet = new uc_PhieuXuatKhoChiTiet();
                        //ucPhieuXuatKhoChiTiet.Location = new Point(0, 0);
                        //ucPhieuXuatKhoChiTiet.Dock = DockStyle.Fill;
                        //this.Controls.Add(ucPhieuXuatKhoChiTiet);
                        break;
                    case "PhieuThu":
                        uc_PhieuThu ucPhieuThu = new uc_PhieuThu();
                        ucPhieuThu.Location = new Point(0, 0);
                        ucPhieuThu.Dock = DockStyle.Fill;
                        this.Controls.Add(ucPhieuThu);
                        break;
                    case "PhieuChi":
                        uc_PhieuChi ucPhieuChi = new uc_PhieuChi();
                        ucPhieuChi.Location = new Point(0, 0);
                        ucPhieuChi.Dock = DockStyle.Fill;
                        
                        this.Controls.Add(ucPhieuChi);
                        break;
                    case "NhapKho":
                        uc_NhapKho ucNhapkho = new uc_NhapKho();
                        ucNhapkho.Location = new Point(0, 0);
                        ucNhapkho.Dock = DockStyle.Fill;
                        ucNhapkho.Close = new uc_NhapKho.CloseForm(ReceiveEvent);
                        this.Controls.Add(ucNhapkho);
                        break;
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        public void ReceiveEvent(bool b)
        {
            if(b == true)
                this.Close();
        }
    }
}